import { createRouter, createWebHistory } from 'vue-router'
import ACCESS_ENUM from '@/access/accessEnum'

const router = createRouter({
	history: createWebHistory(),
	routes: [
		{
			path: '/',
			name: 'home',
			component: () => import('@/views/HomeView.vue'),
		},
		{
			path: '/user/login',
			name: '用户登录',
			component: () => import('@/views/user/UserLoginView.vue'),
		},
		{
			path: '/user/register',
			name: '用户注册',
			component: () => import('@/views/user/UserRegisterView.vue'),
		},
		{
			path: '/user/profile',
			name: '个人主页',
			component: () => import('@/views/user/UserProfileView.vue'),
			meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
		{
			path: '/user/vip',
			name: 'VIP会员',
			component: () => import('@/views/user/UserVipView.vue'),
			meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
		{
			path: '/admin/userManage',
			name: '用户管理',
			component: () => import('@/views/admin/UserManageView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
			path: '/admin/pictureManage',
			name: '图片管理',
			component: () => import('@/views/admin/PictureManageView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
			path: '/admin/spaceManage',
			name: '空间管理',
			component: () => import('@/views/admin/SpaceManagerView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
			path: '/admin/vipManage',
			name: 'VIP管理',
			component: () => import('@/views/admin/VipManageView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
			path: '/spaceUserManage/:id',
			name: '空间成员管理',
			component: () => import('@/views/admin/SpaceUserManagerView.vue'),
      props: true
		},
    {
			path: '/add_picture',
			name: '创建图片',
			component: () => import('@/views/picture/AddPictureView.vue'),
      meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
    {
			path: '/add_space',
			name: '创建空间',
			component: () => import('@/views/space/AddSpaceView.vue'),
      meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
    {
      path: '/my_space',
      name: '我的空间',
      component: () => import('@/views/space/MySpaceView.vue'),
      meta: {
        access: ACCESS_ENUM.USER, // 需要登录
      }
    },
    {
			path: '/add_picture/batch',
			name: '批量创建图片',
			component: () => import('@/views/picture/AddPictureBatchView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
      path: '/picture/:id',
      name: '图片详情',
      component: () => import('@/views/picture/PictureDetailView.vue'),
      props: true, // 允许将路由参数作为 props 传递给组件
    },
    {
      path: '/search_picture',
      name: '图片搜索结果',
      component: () => import('@/views/picture/SearchPictureView.vue'),
      meta: {
        access: ACCESS_ENUM.USER, // 需要登录
      }
    },
    {
      path: '/space/:id',
      name: '空间详情',
      component: () => import('@/views/space/SpaceDetailView.vue'),
      props: true, // 允许将路由参数作为 props 传递给组件
    },
    {
      path: '/space_analyze',
      name: '空间分析',
      component: () => import('@/views/space/SpaceAnalyzeView.vue'),
       meta: {
        access: ACCESS_ENUM.USER, // 需要登录
      }
    },
		{
			path: '/noAuth',
			name: '无权限',
			component: () => import('@/views/error/NoAuthView.vue'),
		},
		{
			path: '/:pathMatch(.*)*',
			name: '404',
			component: () => import('@/views/error/NotFoundView.vue'),
		},
	],
})

export default router
